package com.holly.unit.deform;

import com.holly.unit.db.api.pojo.db.TableInfo;
import com.holly.unit.db.api.pojo.page.PageResult;
import com.holly.unit.deform.api.DeformOnlineApi;
import com.holly.unit.deform.api.pojo.online.pojo.ColumnInfo;
import com.holly.unit.deform.api.pojo.online.pojo.DesignFormOnlineRequest;
import com.holly.unit.deform.context.DeformContext;
import com.holly.unit.deform.entity.DesignFormOnline;
import com.holly.unit.deform.service.DesignFormOnlineFieldService;
import com.holly.unit.deform.service.DesignFormOnlineIndexService;
import com.holly.unit.deform.service.DesignFormOnlineService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class DesignFormOnlineOperator  implements DeformOnlineApi{

    private DesignFormOnlineService onlineService = DeformContext.designFormOnlineService();
    private DesignFormOnlineFieldService fieldService = DeformContext.designFormOnlineFieldService();
    private DesignFormOnlineIndexService indexService = DeformContext.designFormOnlineIndexService();

    @Override
    public PageResult<DesignFormOnline> queryPageList(DesignFormOnlineRequest designFormOnlineDTO) {
        return onlineService.queryPageList(designFormOnlineDTO);
    }

    public List<TableInfo> queryPageListFrom() {
        return onlineService.queryPageListFrom();
    }

    @Override
    public void add(DesignFormOnlineRequest designFormOnlineDTO) {
        onlineService.add(designFormOnlineDTO);
    }

    @Override
    public void update(DesignFormOnlineRequest designFormOnlineDTO) {
        onlineService.updateDesignForm(designFormOnlineDTO);
    }

    @Override
    public Map<String, List> listByHead(String id) {
        Map<String, List> hashMap = new HashMap<>();
        hashMap.put("head",fieldService.listByHead(id));
        hashMap.put("indexs",indexService.listHead(id));
        return hashMap;
    }

    @Override
    public List<ColumnInfo> listByHeadId(String cgformCode) {
        return onlineService.listByHeadId(cgformCode);
    }

    @Override
    public void deleteTable(String id, String tableName) {
        onlineService.deleteTable(id,tableName);
    }

}
